Update File Upload Success
Description
The update_file_upload_success
function is responsible for notifying the web service that a file upload has completed successfully. This function takes a device name and file ID as parameters, sends a request to mark the file upload as successful, and returns the HTTP response details.
Function Signature:
def update_file_upload_success(ws_config: WebServiceConfig, device_name: str, file_id: int) -> WebServiceResult:
Parameters
- ws_config (WebServiceConfig): Configuration object for the web service.
- device_name (str): The serial number of the device associated with the file upload.
- file_id (int): The ID of the file that is being marked as successfully uploaded.
Returns
- WebServiceResult: The result of the web service request, which includes:
- http_response_code: The HTTP response code from the server (e.g., 200 for success).
- http_response_string: The response body from the server, which may contain additional details or errors.
Example Usage
ws_config = WebServiceConfig(base_url="https://api.actionstreamer.com")
device_name = "Device1"
file_id = 12345
result = update_file_upload_success(ws_config, device_name, file_id)
print(result.http_response_code, result.http_response_string)
Behavior
- Sends a
POST
request to the server to mark the file upload as successful, using the specified file ID and device name. - If the request is successful (HTTP 200), the response will contain a success message.
- Returns a
WebServiceResult
containing the response code and message.
Error Handling
- General Exception: If any exception occurs during the request or processing, the function logs the error, sets the response code to
-1
, and includes a message in the response string indicating the failure.